package com.frxuexi.lib_base.http

import com.frxuexi.lib_base.entity.CartBean
import com.frxuexi.lib_base.entity.CommentBean
import com.frxuexi.lib_base.entity.CreateOrderRespBean
import com.frxuexi.lib_base.entity.GetPreOrderRespBean
import com.frxuexi.lib_base.entity.HomeBean
import com.frxuexi.lib_base.entity.OrderBean
import com.frxuexi.lib_base.entity.PayOrderRespBean
import com.frxuexi.lib_base.entity.PreOrderRespBean
import com.frxuexi.lib_base.entity.Res
import com.frxuexi.lib_base.entity.ShopBean
import com.frxuexi.lib_base.entity.ShopBeanItem
import com.frxuexi.lib_base.entity.ShopDetailBean
import com.frxuexi.lib_base.entity.UploadBean
import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface ShopApiService {
    @GET("/api/front/index")
    fun getHomeData():Flow<Res<HomeBean>>

    @GET("/api/front/index/product/{type}?limit=10")
    fun getShops(@Path("type")type:Int,@Query("page")page:Int):Flow<Res<ShopBean>>

    @GET("/api/front/products?page=1&limit=20")
    fun getShopsByKey(@Query("keyword")keyword:String):Flow<Res<ShopBean>>

    @GET("/api/front/product/detail/{id}?type=normal")
    fun getShopById(@Path("id")id:Int):Flow<Res<ShopDetailBean>>

    @POST("/api/front/cart/save")
    fun addCart(@Body body: RequestBody):Flow<Res<Any>>

    @GET("/api/front/cart/list?isValid=true&limit=20")
    fun getCarts(@Query("page")page:Int):Flow<Res<CartBean>>

    @POST("/api/front/cart/num")
    fun updateCart(@Query("id")id:Int,@Query("number")number:Int):Flow<Res<Any>>

    @POST("/api/front/cart/delete")
    fun deleteCart(@Query("ids")ids:List<Int>):Flow<Res<Any>>

    @POST("/api/front/order/pre/order")
    fun repreOrder(@Body body: RequestBody):Flow<Res<PreOrderRespBean>>

    @GET("/api/front/order/load/pre/{preOrderNo}")
    fun getPreOrder(@Path("preOrderNo")preOrderNo:String):Flow<Res<GetPreOrderRespBean>>

    @POST("/api/front/order/create")
    fun createOrder(@Body body: RequestBody):Flow<Res<CreateOrderRespBean>>

    @GET("/api/front/order/list?limit=20&page=1")
    fun getOrders(@Query("type")type:Int):Flow<Res<OrderBean>>

    @POST("/api/front/order/cancel")
    fun cancelOrder(@Query("id")id:Int):Flow<Res<Boolean>>

    @POST("/api/front/pay/payment")
    fun payOrder(@Body body: RequestBody):Flow<Res<PayOrderRespBean>>

    @GET("/api/front/reply/list/{id}?limit=20&page=1&type=0")
    fun getComments(@Path("id")id:Int):Flow<Res<CommentBean>>

    @POST("/api/front/order/comment")
    fun addComment(@Body body: RequestBody):Flow<Res<Boolean>>

    @Multipart
    @POST("/api/front/user/upload/image")
    fun upload(@Part list:List<MultipartBody.Part>,@Query("model")model:String,@Query("pid")pid:Int):Flow<Res<UploadBean>>

    @POST("/api/front/order/refund")
    fun refundOrder(@Body body: RequestBody):Flow<Res<Boolean>>

}